wayland: Check actual impl type in transient loop
authorOlivier Fourdan <ofourdan@redhat.com>
Mon, 29 Feb 2016 09:14:56 +0000 (10:14 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 2 Mar 2016 03:18:32 +0000 (22:18 -0500)
If the parent of a transient is not a native Wayland window (e.g.
offscreen window), the transient loop check will crash.

Check for the actual type in the transient loop check and do not assume
the parent is necessarily Wayland native.

bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=761156

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
gdk/wayland/gdkwindow-wayland.c

index 34c6805ce88e33ef9a66a6ff99aa520d6de3b4c9..9439c1abc614dae61a26f35c78f0c6844e79ccc6 100644 (file)
@@ -946,8 +946,12 @@ gdk_wayland_window_update_dialogs (GdkWindow *window)
   for (l = orphan_dialogs; l; l = l->next)
     {
       GdkWindow *w = l->data;
-      GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (w->impl);
+      GdkWindowImplWayland *impl;
+
+      if (!GDK_IS_WINDOW_IMPL_WAYLAND(w->impl))
+        continue;
 
+      impl = GDK_WINDOW_IMPL_WAYLAND (w->impl);
       if (w == window)
        continue;
       if (impl->hint != GDK_WINDOW_TYPE_HINT_DIALOG)
@@ -2215,8 +2219,12 @@ check_transient_for_loop (GdkWindow *window,
 {
   while (parent)
     {
-      GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (parent->impl);
+      GdkWindowImplWayland *impl;
+
+      if (!GDK_IS_WINDOW_IMPL_WAYLAND(parent->impl))
+        return FALSE;
 
+      impl = GDK_WINDOW_IMPL_WAYLAND (parent->impl);
       if (impl->transient_for == window)
         return TRUE;
       parent = impl->transient_for;